package com.lorenzogao.latte_core.activity

import android.annotation.SuppressLint
import android.os.Bundle
import androidx.appcompat.widget.ContentFrameLayout
import com.lorenzogao.latte_core.R
import com.lorenzogao.latte_core.delegates.LatteDelegate
import me.yokeyword.fragmentation.SupportActivity

/**
 * create by LorenzoGao
 * email: 2508719070@qq.com
 * TIME: 2020-01-08 10:37
 * description:
 */

abstract class ProxyActivity : SupportActivity() {

    abstract fun setRootDelegate(): LatteDelegate


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        initContainer(savedInstanceState)

    }

    @SuppressLint("RestrictedApi")
    private fun initContainer(savedInstanceState: Bundle?) {
        val container = ContentFrameLayout(this)
        container.id = R.id.delegate_container
        setContentView(container)
        if (savedInstanceState == null) {
            loadRootFragment(R.id.delegate_container, setRootDelegate())
        }


    }

    override fun onDestroy() {
        super.onDestroy()
        System.gc()
        System.runFinalization()
    }


}
